<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1.0,user-scalable=no" />
    <link rel="stylesheet" href="__CSS__/common.css">
    <link rel="stylesheet" href="__CSS__/alipay.css">
    <title>支付宝提现</title>
</head>
<body>
<form method="post" action="{:url('user/cash')}">
<div class="top">
    <p id="extractable">
        可提现金额（元）<span>{$user.user_money}</span>
    </p>
    <p>请输入提现金额（元）</p>
    <div>
        <input type="text" id="money" name="money">
    </div>
</div>
<div class="bind-box">
    <dl class="buf_item">
        <dt>支付宝账户</dt>
        <dd>
            <input type="hidden" id="bank_name" name="bank_name" value="支付宝">
            <input type="hidden" id="realname" name="realname" value=" ">
            <input type="text" id="alipay_num" name="bank_card" placeholder="输入支付宝账户">
        </dd>
    </dl>
    <dl class="buf_item">
        <dt>手机号</dt>
        <dd>
            <input type="text" id="phone" name="mobile" placeholder="输入手机号">
        </dd>
    </dl>
</div>

<button class="btn"  onclick="return withdraw()">提 现</button>
</form>
</body>
<script src="__JS__/jquery.min.js"></script>
<script src="__JS__/layer.js"></script>
<script src="__JS__/float_mony.js"></script>
<script type="text/javascript">
    function withdraw() {
        var phone=$('#phone').val().trim();
        var alipay_num=$('#alipay_num').val().trim();
        var extractable= tonum($('#extractable>span').html());
        // console.log(extractable);
        var money=parseFloat($('#money').val().trim());
        if(!money){layer.msg("请输入提现金额",{time:1500})}
        else if(money>extractable){layer.msg("提现金额不能超过现有金额",{time:1500})}
        else if(!alipay_num){layer.msg("请输入支付宝账户",{time:1500})}
        else if(!phone){layer.msg("请输入预留手机号",{time:1500})}
        else{
            $.ajax({
                type:'post',
                url:$("form").attr('action'),
                data:$("form").serialize(),
                success:function (data){
                    if(data.code==1){
                        layer.msg(data.msg,{time:1500});
                        location.href=data.data
                    }else{
                        layer.msg(data.msg,{time:1500});
                    }
                },
                error:function () {

                }

            })
        }
        return false;
    }

</script>
</html>